//
//  SecondViewController.m
//  AssistantDriving
//
//  Created by dcr on 2017/8/28.
//  Copyright © 2017年 邓兆太. All rights reserved.
//

#import "SecondViewController.h"
#import "FirstCell.h"
#import "PlayerViewController.h"

@interface SecondViewController ()<UITableViewDelegate, UITableViewDataSource>

@property(nonatomic, strong)NSArray *titles;

@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"科目二";
    _titles = [NSArray arrayWithObjects:@"视频1", @"视频2", @"视频3", @"视频4", @"视频5", nil];
    UITableView *table = [self tableView];
    [self.view addSubview:table];
    table.dataSource = self;
    table.delegate = self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    FirstCell * cell = [FirstCell cellWithTableView:tableView];
    
    cell.iconImageView.image = [UIImage imageNamed:@"204"];
    cell.titleLabel.text = _titles[indexPath.row];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [FirstCell cellHeight];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    [self selectItem:(int)indexPath.row];
}

- (void)selectItem:(int)row{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"aaaaa" ofType:@"mp4"];
    
    PlayerViewController *movie = [PlayerViewController new];
    movie.url = [NSURL fileURLWithPath:path];
    movie.title = _titles[row];
    [self.navigationController showViewController:movie sender:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
